package middle;

public class Solution_11 {

    public int maxArea(int[] height) {
        int left = 0, right = height.length - 1;
        int max = 0;
        while (left < right) {
            int value = Math.min(height[left], height[right]) * (right - left);
            max = Math.max(max, value);
            if (height[left] < height[right]) {
                left++;
            } else {
                right--;
            }
        }
        return max;
    }

    public static void main(String[] args) {
        Solution_11 model = new Solution_11();
        System.out.println(model.maxArea(new int[]{1, 8, 6, 2, 5, 4, 8, 3, 7}));
        System.out.println(model.maxArea(new int[]{1, 1}));
        System.out.println(model.maxArea(new int[]{4, 3, 2, 1, 4}));
    }
}
